From ee4f0df6bd686bf58594fca394dfaf3ba153d92c Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Sun, 2 Nov 2025 17:40:14 +0100 Subject: [PATCH] netlink: Store interface MTU at link change MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is used for clamping MTU values. Signed-off-by: Paul Donald Link: https://github.com/openwrt/odhcpd/pull/296 Signed-off-by: Álvaro Fernández Rojas --- src/netlink.c | 7 +++++++ src/odhcpd.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/netlink.c b/src/netlink.c index 5b3dc66..6de9ae7 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -257,6 +257,13 @@ static int handle_rtm_link(struct nlmsghdr *hdr) iface->ifflags = ifi->ifi_flags; + /* store current MTU if available */ + if (nla[IFLA_MTU]) { + iface->if_mtu = nla_get_u32(nla[IFLA_MTU]); + debug("Netlink setting interface '%s' if_mtu MTU to %d", + iface->name, iface->if_mtu); + } + /* * Assume for link event of the same index, that link changed * and reload services to enable or disable them based on the diff --git a/src/odhcpd.h b/src/odhcpd.h index 55107e5..e503029 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -333,6 +333,7 @@ struct interface { int ifindex; char *ifname; const char *name; + uint32_t if_mtu; // IPv6 runtime data struct odhcpd_ipaddr *addr6; -- 2.30.2